import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '../views/Layout.vue'

Vue.use(VueRouter)

const routes = [
  //==== 登录 ====
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/login/Login.vue'),
  },
  //====主页====
  {
    path: '/',
    name: 'Layout',
    component:Layout,
    redirect:'/home',

    children:[  //子路由

      {
        path: 'home',
        name: 'Home',
        component: ()=>import('@/views/home/HomeView.vue')

      },
      //==== User====
      {
        path: 'questionList',
        name: 'QuestionList',
        component: ()=>import('@/views/question/Question.vue')

      },
      {
        path: 'editQuestion',
        name: 'EditQuestion',
        component: ()=>import('@/views/question/EditQuestion.vue')

      },
      {
        path: 'addQuestion',
        name: 'AddQuestion',
        component: ()=>import('@/views/question/AddQuestion.vue')

      },
      //====Admin===
      {
        path: 'adminList',
        name: 'AdminList',
        component: ()=>import('@/views/admin/List.vue')

      },
      {
        path: 'editAdmin',
        name: 'EditAdmin',
        component: ()=>import('@/views/admin/Edit.vue')

      },
      {
        path: 'addAdmin',
        name: 'AddAdmin',
        component: ()=>import('@/views/admin/Add.vue')

      },
    //====Category====
      {
        path: 'categoryList', name: 'CategoryList', component: ()=>import('@/views/category/List.vue')},
      {path: 'editCategory', name: 'EditCategory', component: ()=>import('@/views/category/Edit.vue')},
      {path: 'addCategory', name: 'AddCategory', component: ()=>import('@/views/category/Add.vue')},
      //====Paper====
      {
        path: 'paperList', name: 'PaperList', component: ()=>import('@/views/paper/List.vue')},
      {path: 'editPaper', name: 'EditPaper', component: ()=>import('@/views/paper/Edit.vue')},
      {path: 'addPaper', name: 'AddPaper', component: ()=>import('@/views/paper/Add.vue')},
    ]
  }

]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
